package net.xxcxcxcx.xc_enhancedmob.skills.basics.individual.rare;

import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.damage.DamageSource;
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.entity.mob.MobEntity;
import net.minecraft.nbt.NbtCompound;
import net.xxcxcxcx.xc_enhancedmob.config.skill.SkillConfig;
import net.xxcxcxcx.xc_enhancedmob.register.StatusEffectRegister;
import net.xxcxcxcx.xc_enhancedmob.skills.BaseSkill;
import net.xxcxcxcx.xc_enhancedmob.skills.Ref;
import net.xxcxcxcx.xc_enhancedmob.skills.SkillRarity;

public class TraumaSkill extends BaseSkill {
    public TraumaSkill(int level) {
        super(level);
    }

    public TraumaSkill(NbtCompound nbtCompound) {
        super(nbtCompound);
    }

    public TraumaSkill() {
    }

    @Override
    public SkillConfig getDefaultConfig() {
        SkillConfig skillConfig = super.getDefaultConfig();
        skillConfig.setMessage(getConfigMessage(skillConfig));
        return skillConfig;
    }

    @Override
    public String getConfigMessage(SkillConfig skillConfig) {
        if (skillConfig == null) return super.getConfigMessage(null);
        return String.format("创伤技能，使目标受到伤害增加(10*level%%)并减少治疗量(10*level%%)，持续（20+level*2）秒。(10级治疗归零)");
    }

    public SkillRarity getSkillRarity() {
        return SkillRarity.Rare;
    }

    @Override
    public boolean onAttack(MobEntity attacker, LivingEntity target, DamageSource source, Ref<Float> amount, boolean ismob, boolean remote) {
        if (target != null)
            target.addStatusEffect(new StatusEffectInstance(StatusEffectRegister.Prohibition, 20 * (20 + getSkillLevel() * 2), getSkillLevel()));
        return true;
    }
}
